package com.gdut.huayan.controller;

import com.gdut.huayan.entity.dto.Result;
import com.gdut.huayan.entity.vo.IdsVo;
import com.gdut.huayan.service.PrintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/print")
public class PrintController {

    @Autowired
    private PrintService printService;


    @PreAuthorize("hasAnyAuthority('SUPER_ADMIN')")
    @GetMapping("/getPaidTablet")
    public Result getPaidTablet(Long festivalId, Long locationId, Long activityId,Integer printType) {
        return Result.success(printService.getPaidTabletByDetailId(festivalId, locationId, activityId,printType));
    }

    @PreAuthorize("hasAnyAuthority('SUPER_ADMIN')")
    @PostMapping("/getPdf")
    public void getTabletPaperByIdsV1(@RequestBody IdsVo idsVo, HttpServletResponse response) throws IOException {
        printService.getTabletPaperByIdsV1(idsVo.getIds(), response);
    }

    @PreAuthorize("hasAnyAuthority('SUPER_ADMIN')")
    @PostMapping("/v2/getPdf")
    public void getTabletPaperByIdsV2(@RequestBody IdsVo idsVo, HttpServletResponse response) throws IOException {
        printService.getTabletPaperByIdsV2(idsVo.getIds(), response);
    }



}
